import { createStore } from 'redux'

// createStore(reducer, initState, 中间件) 接收三个参数


// reducer
// 1. 根据action.type 对数据进行处理
// 2. 返回数据


// 在reducer中可以接收两个参数
// 参数1. state ==>  初始数据
// 参数2. action
let reducer = (state, action) => {
    console.log(action)
    if (action.type === 'ADD_COUNT') {
        state.count += 1
    } else if (action.type === 'DEL_COUNT') {
        state.count -= 1
    } else {

    }
    console.log(state)
    return state
}

let initState = {
    count: 100,
    name: "张三"
}

let store = createStore(reducer, initState)

// 方便调试
window.store = store

export default store
